/*
 * utils.h
 *
 *  Created on: 2016-3-29
 *      Author: Administrator
 */

#ifndef UTILS_H_
#define UTILS_H_
#define IOException "java/io/IOException"
//MAX log message length
#define MAX_LOG_MESSAGE_LENGTH 256
//MAX data buffer size
#define MAX_BUFFER_SIZE 80
#define MAX_LINE 1024
#define  TAG    "jni"
#define   LOG_TAG    "LOG_TEST"
#define   LOGI(...)  __android_log_print(ANDROID_LOG_INFO,LOG_TAG,__VA_ARGS__)
int port=9331;
#include <jni.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <jni.h>
#include <sys/select.h>
#include <sys/socket.h>
#include <arpa/inet.h>
#include <android/log.h>
#include <unistd.h>
#include <net/if.h>
#include "cJSON.h"

static void ThrowException(JNIEnv* env,const char* message);

static void ThrowException(JNIEnv* env,const char* message) {
	jclass clazz = env->FindClass(IOException);
	if (clazz != NULL) {
		env->ThrowNew(clazz, message);
		env->DeleteLocalRef(clazz);
	}
}

static char* intToChar(int i){

	char c[5]={'P','0','0','0','0'};
	int res=0;
	int p=4;
	while(i/10!=0){
		res=i%10;
		c[p]=res+'0';
		i/=10;
		p--;
	}
	if(i!=0){
		c[p]=i+'0';
	}
	LOGI("%s",c);
	return c;

}


#endif /* UTILS_H_ */


